<template>
  <div>
    <el-container>
      <el-header>

        <div class="BackTitle">
          <BackTitle size="55px"></BackTitle>
        </div>

        <div class="exit" @click="toList">
          退出
        </div>



      </el-header>
      <el-main>
<!--        <router-view></router-view>-->
        <div class="progress-bar-long">
          <div class="progress-bar-short"></div>
        </div>
        <div class="title">
          为活动命名，并选择合适的封面图
        </div>
        <div class="description">
          活动名一般不超过64字，图片大小不超过2mb，宽度不超过390px，格式限制为png或jpg。
        </div>
        <div class="input">
          <el-input
              placeholder="输入活动名"
              prefix-icon="el-icon-message"
              v-model="$store.state.editedEvent.title">
          </el-input>
        </div>

        <div class="upload">
          <el-upload
              action=""
              :limit="1"
              :on-change="handleChange"
              :auto-upload="false"
              :file-list="fileList"
              :show-file-list="false">
            <img v-if="imageUrl" :src="imageUrl" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
<!--          <el-upload-->
<!--              class="upload-demo"-->
<!--              show-file-list-->
<!--              drag-->
<!--              :auto-upload="false"-->
<!--              action="https://jsonplaceholder.typicode.com/posts/"-->

<!--              :on-change="test"-->
<!--              >-->
<!--            <i class="el-icon-upload"></i>-->
<!--            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>-->
<!--            <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>-->
<!--          </el-upload>-->
        </div>
      </el-main>
      <el-footer>

        <div class="button">
          <el-button @click="toDetail2">返回</el-button>
          <el-button @click="toDetail4">下一步</el-button>
        </div>

      </el-footer>
    </el-container>
  </div>
</template>

<script>
import BackTitle from "@/components/BackTitle";
import BackButton from "@/components/BackButton";
export default {
  components: {BackButton, BackTitle},
  data() {
    return {
      fileList:[],
      imageUrl:this.$store.state.editedEvent.cover_url
    }
  },
  methods: {
    toList() {
      this.$router.push({
        name:'List'
      })
    },
    toDetail2() {
      this.$router.push({
        name:'Detail2'
      })
    },
    toDetail4(){
      this.$router.push({
        name:'Detail4'
      })
    },
    handleChange(file, fileLists) {
      console.log(file);
      console.log(fileLists);
      // 本地服务器路径
      console.log(URL.createObjectURL(file.raw));
      // 本地电脑路径
      console.log(document.getElementsByClassName("el-upload__input")[0].value);
    },

  },
}
</script>

<style scoped>
.el-container{
  width: 100%;
  height: 100%;
  position: absolute;
}

.BackTitle{
  /*!*方便观察分区，画出分区边界*!*/
  /*border: 1px solid red;*/

  width: 30%;

  margin-left: -4%;
  margin-top: -1%;
}

.exit{
  /*!*方便观察分区，画出分区边界*!*/
  /*border: 1px solid red;*/

  float:right;

  margin-top: -1.3%;

  font-size: 20px;
}

/*.progress-bar{*/
/*  !*方便观察分区，画出分区边界*!*/
/*  border: 1px solid red;*/

/*  width: 100%;*/
/*  height: 1%;*/
/*  position: absolute;*/
/*  margin-left: -1.1%;*/
/*  margin-top: 0.7%;*/
/*}*/

.button{
  /*!*方便观察分区，画出分区边界*!*/
  /*border: 1px solid red;*/

  float: right;
  margin-right: 7%;
  margin-top: 0.5%;


}

.el-footer{
  border-top-style: solid;
  border-top-width:1px;
  border-top-color:#BBBBBB;
}
.el-button{
  background-color: #F65858;
  color: #fff;

  font-weight: 700;

  border-radius: 5px;;
  border:none;

  width:240px;
  height: 40px;
}

.progress-bar-long{
  /*!*方便观察分区，画出分区边界*!*/
  /*border: 1px solid red;*/

  background-color: #CECECE;

  width: 100%;
  height: 2%;
  position: absolute;
  margin-left: -1.02%;

}

.progress-bar-short{
  /*!*方便观察分区，画出分区边界*!*/
  /*border: 1px solid red;*/
  background-color: #008294;

  width: 20%;
  height: 100%;
  position: absolute;
}

.title{
  /*方便观察分区，画出分区边界*/
  border: 1px solid red;

  position: absolute;
  margin-top: 5%;
  margin-left: 35%;

  font-size: 50px;
  font-weight: 600;
}
.description{
  /*方便观察分区，画出分区边界*/
  border: 1px solid red;

  position: absolute;
  margin-top: 10%;
  margin-left: 40%;

  font-weight: 600;
}

.input{
  /*方便观察分区，画出分区边界*/
  border: 1px solid red;

  position: absolute;
  margin-top: 20%;
  margin-left: 35%;
}

.upload{
  position: absolute;
  margin-top: 30%;
  margin-left: 35%;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
